<?php

//VideoFlow - Joomla Multimedia System for Facebook//
/**
* @ Version 1.1.2 
* @ Copyright (C) 2008 - 2010 Kirungi Fred Fideri at http://www.fidsoft.com
* @ VideoFlow is free software
* @ Visit http://www.fidsoft.com for support
* @ Kirungi Fred Fideri and Fidsoft accept no responsibility arising from use of this software 
* @ Released under GNU/GPL License : http://www.gnu.org/copyleft/gpl.html
**/

// No direct access
 
defined('_JEXEC') or die('Restricted access'); 

//Get settings
global $vparams;

//Load Stylesheet
$doc = &JFactory::getDocument();
$css = JURI::root().'components/com_videoflow/views/videoflow/tmpl/css/lightbox_play.css';
$doc->addStyleSheet( $css, 'text/css', null, array() );

$xp = JRequest::getInt('xp');
$media = $this->media;

if (stripos($media->embedcode, 'swfobject.embedSWF') !== false){
    $swfobject = JURI::root().'components/com_videoflow/jscript/swfobject.js';
    $doc->addScript($swfobject);
    $doc->addScriptDeclaration ($media->embedcode);
    $altcontent = '<a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash">You must get the Adobe Flash Player to see this media content.</a>';
} else {
     $altcontent = $media->embedcode;
}

// Load VOTItaly Rating System

if ($vparams -> ratings) {
          
    // Load rating CSS
    $ratingcss = JURI::root().'components/com_videoflow/extra/votitaly/css/votitaly.css';
    $doc->addStyleSheet( $ratingcss, 'text/css', null, array() );
    
    //Initialise VOTItaly script
    $vratings ='
    '."
	   window.addEvent('domready', function(){
	     var vf_rate = new VotitalyPlugin({
	  	    submiturl: '".JURI::base()."index.php?option=com_videoflow&task=vote&format=raw',
		      loadingimg: '".JURI::base()."components/com_videoflow/extra/votitaly/images/loading.gif',
			    show_stars: ".($vparams->showstars ? 'true' : 'false').",
			    star_description: '".addslashes($vparams->stardesc)."',		
			    language: {
				  updating: '".addslashes(JText::_( 'Updating...'))."',
				  thanks: '".addslashes(JText::_( 'Thanks for voting!'))."',
				  already_vote: '".addslashes(JText::_( 'You have already voted for this item!'))."',
				  votes: '".addslashes(JText::_( 'votes'))."',
				  vote: '".addslashes(JText::_( 'vote'))."',
				  average: '".addslashes(JText::_( 'average'))."',
				  outof: '".addslashes(JText::_( 'out of 5'))."',
				  error1: '".addslashes(JText::_( 'An error has occured!'))."',
				  error2: '".addslashes(JText::_( 'You have already voted for this item!'))."',
				  error3: '".addslashes(JText::_( 'Rating out of range!'))."',
				  error4: '".addslashes(JText::_( 'You must login to vote!'))."',
				  error5: '".addslashes(JText::_( 'User rating already submitted for this item!'))."'
			    }
	       });
	     });
      ".'
    ';
    $doc->addScriptDeclaration ($vratings);		          

// Load rating js file
    $ratingjs = JURI::root().'components/com_videoflow/extra/votitaly/js/votitaly.js';
    $doc->addScript ($ratingjs);
    
if ($vparams->playall && $vparams->prostatus) {
$vfbox = "
  var vf_player;
  var vfState = 'fideri';
  
  function computeEnd(){
			myVfbox(0);
			}
			
  function playerReady(obj) {
	vf_player = document.getElementById('vf_fidsPlayer');
  vf_player.addModelListener('STATE', 'myVfbox');
  };
  
  function onYouTubePlayerReady(obj) {
  vf_player = document.getElementById ('vf_fidsPlayer');
  vf_player.addEventListener('onStateChange', 'myVfbox');
  }
  
  function yReady(obj) {
  alert('Yready!');
  vf_player = document.getElementById ('vf_fidsPlayer');
  vf_player.addEventListener('StateChange', 'myVfbox');
  }
  
  function onDailymotionPlayerReady(obj){
  vf_player = document.getElementById ('vf_fidsPlayer');
  vf_player.addEventListener('onStateChange', 'myVfbox');
  }
  
  function myVfbox(obj){
  var	currentState = obj.newstate; 
  var vfState = obj;
    if (currentState === 'COMPLETED' || vfState === 0){
    parent.document.getElementById('MultiBoxNext').fireEvent('dblclick');
    }
  }
"; 

  if (empty($xp)) {
  $doc->addScriptDeclaration ($vfbox);		   
  }
}   
}         



?>
<div id="vf_multibox" style="z-index:10; overflow:hidden;">
<table width="100%" cellspacing="0" cellpadding="0" align="center">
<tbody>
<tr><td align="center">
<div id="vfmediaspace" style="min-height:<?php echo $vparams->playerheight.'px'; ?>; z-index:100;"><?php echo $altcontent; ?></div>
</td></tr>
<tr><td>
<div class="mod_vfshare"><?php echo $this->vflike; ?></div>
<?php if ($vparams->ratings) echo '<div class="vf_rating">'.$this->rating.'</div>'; ?>
</td></tr>
<tr><td align="center">
<div id="mod_vflow5" style="max-width:<?php echo $vparams->playerwidth.'px'; ?>;"><?php echo $this->vflow5; ?></div>
</td></tr>
</tbody>
</table>
</div>
<?php
if ($vparams->facebook){
?>
<script type="text/javascript">
function initFB() {
	FB_RequireFeatures(["XFBML"], function(){
		FB.init("<?php echo $vparams->fbkey; ?>", "<?php echo JURI::root().'components/com_videoflow/fbook/xd_receiver.htm'; ?>");
	});}

function quitFB(){
  FB.Connect.logoutAndRedirect ("<?php echo JRoute::_(JURI::root().'index.php?option=com_videoflow'); ?>");
} 
</script>	
<?php
}